package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.JobLogDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.JobLog;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface JobLogMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    BasicColumn[] selectList = BasicColumn.columnList(jobLogId, className, createTime, cron, status, jobName, jobParams, runTime, exception);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<JobLog> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("JobLogResult")
    Optional<JobLog> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="JobLogResult", value = {
        @Result(column="job_log_id", property="jobLogId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="class_name", property="className", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="cron", property="cron", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.SMALLINT),
        @Result(column="job_name", property="jobName", jdbcType=JdbcType.VARCHAR),
        @Result(column="job_params", property="jobParams", jdbcType=JdbcType.VARCHAR),
        @Result(column="run_time", property="runTime", jdbcType=JdbcType.VARCHAR),
        @Result(column="exception", property="exception", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<JobLog> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, jobLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, jobLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default int deleteByPrimaryKey(Long jobLogId_) {
        return delete(c -> 
            c.where(jobLogId, isEqualTo(jobLogId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default int insert(JobLog record) {
        return MyBatis3Utils.insert(this::insert, record, jobLog, c ->
            c.map(jobLogId).toProperty("jobLogId")
            .map(className).toProperty("className")
            .map(createTime).toProperty("createTime")
            .map(cron).toProperty("cron")
            .map(status).toProperty("status")
            .map(jobName).toProperty("jobName")
            .map(jobParams).toProperty("jobParams")
            .map(runTime).toProperty("runTime")
            .map(exception).toProperty("exception")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default int insertSelective(JobLog record) {
        return MyBatis3Utils.insert(this::insert, record, jobLog, c ->
            c.map(jobLogId).toPropertyWhenPresent("jobLogId", record::getJobLogId)
            .map(className).toPropertyWhenPresent("className", record::getClassName)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(cron).toPropertyWhenPresent("cron", record::getCron)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(jobName).toPropertyWhenPresent("jobName", record::getJobName)
            .map(jobParams).toPropertyWhenPresent("jobParams", record::getJobParams)
            .map(runTime).toPropertyWhenPresent("runTime", record::getRunTime)
            .map(exception).toPropertyWhenPresent("exception", record::getException)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default Optional<JobLog> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, jobLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default List<JobLog> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, jobLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default List<JobLog> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, jobLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default Optional<JobLog> selectByPrimaryKey(Long jobLogId_) {
        return selectOne(c ->
            c.where(jobLogId, isEqualTo(jobLogId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, jobLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    static UpdateDSL<UpdateModel> updateAllColumns(JobLog record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(jobLogId).equalTo(record::getJobLogId)
                .set(className).equalTo(record::getClassName)
                .set(createTime).equalTo(record::getCreateTime)
                .set(cron).equalTo(record::getCron)
                .set(status).equalTo(record::getStatus)
                .set(jobName).equalTo(record::getJobName)
                .set(jobParams).equalTo(record::getJobParams)
                .set(runTime).equalTo(record::getRunTime)
                .set(exception).equalTo(record::getException);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(JobLog record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(jobLogId).equalToWhenPresent(record::getJobLogId)
                .set(className).equalToWhenPresent(record::getClassName)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(cron).equalToWhenPresent(record::getCron)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(jobName).equalToWhenPresent(record::getJobName)
                .set(jobParams).equalToWhenPresent(record::getJobParams)
                .set(runTime).equalToWhenPresent(record::getRunTime)
                .set(exception).equalToWhenPresent(record::getException);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default int updateByPrimaryKey(JobLog record) {
        return update(c ->
            c.set(className).equalTo(record::getClassName)
            .set(createTime).equalTo(record::getCreateTime)
            .set(cron).equalTo(record::getCron)
            .set(status).equalTo(record::getStatus)
            .set(jobName).equalTo(record::getJobName)
            .set(jobParams).equalTo(record::getJobParams)
            .set(runTime).equalTo(record::getRunTime)
            .set(exception).equalTo(record::getException)
            .where(jobLogId, isEqualTo(record::getJobLogId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.598+08:00", comments="Source Table: sys_job_log")
    default int updateByPrimaryKeySelective(JobLog record) {
        return update(c ->
            c.set(className).equalToWhenPresent(record::getClassName)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(cron).equalToWhenPresent(record::getCron)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(jobName).equalToWhenPresent(record::getJobName)
            .set(jobParams).equalToWhenPresent(record::getJobParams)
            .set(runTime).equalToWhenPresent(record::getRunTime)
            .set(exception).equalToWhenPresent(record::getException)
            .where(jobLogId, isEqualTo(record::getJobLogId))
        );
    }
}